home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 147 / Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z / Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin / tools / spsx / spsx_s01.lzh / SRC / playctrljob.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-24  |  3.8 KB  |  168 lines

  1. #include <method\methodSx.h>
  2. #include <sxlib.h>
  3. #include "pcm8pp.h"
  4. #include "spsx.h"
  5.  
  6. remote extern    stPlayList_t    stPlayList;            /* 再生ファイルの一覧の構造体 */
  7. extern    int                iPlayMode;
  8.  
  9. uchar        acFileName[256];            /* 再生ファイル名                         */
  10. int            iPlayFlag;                    /* 再生フラグ(1曲)( 0:再生終了 1:再生中)        */
  11. int            iIsPlaying;                    /* 再生フラグ(全体) */
  12.  
  13. int            iPlayTrack;
  14. uchar        *pcPlayTitle;
  15.  
  16. /* 操作ボタン用イメージのポインタ */
  17. extern rectImg **pImgPlayButton;            /* 再生ボタン */
  18. extern rectImg **pImgStopButton;            /* 停止ボタン */
  19. extern rectImg **pImgNextButton;            /* 次曲ボタン */
  20. extern rectImg    **pImgBeforeButton;            /* 前曲ボタン */
  21. extern rectImg **pImgRandomButton;            /* ランダムボタン */
  22. extern rectImg **pImgPauseButton;            /* 一時停止ボタン */
  23. extern rectImg **pImgRestartButton;        /* 再開ボタン */
  24. extern rectImg **pImgDisRndButton;            /* ランダム取り消しボタン */
  25. extern rectImg **pImgPushPlayButton;        /* 再生ボタンを押した状態 */
  26. extern rectImg **pImgPushStopButton;        /* 停止ボタンを押した状態 */
  27. extern rectImg **pImgPushNextButton;        /* 次曲ボタンを押した状態 */
  28. extern rectImg **pImgPushBeforeButton;        /* 前曲ボタンを押した状態 */
  29. extern rectImg **pImgPushRndButton;        /* ランダムボタンを押した状態 */
  30. extern rectImg **pImgPushPauseButton;        /* 一時停止ボタンを押した状態 */
  31. extern rectImg **pImgPushRestartButton;    /* 再開ボタンを押した状態 */
  32. extern rectImg    **pImgPushDisRndButton;        /* ランダム取り消しボタンを押した状態 */
  33.  
  34.  
  35. extern rectImg **pImageH[5];        /* イメージボタン配列(通常ボタン)     */
  36. extern rectImg **pImageL[5];        /*          (押されている時) */
  37.  
  38. extern method_t    mCtrlButton;
  39.  
  40. extern job_t jobPcmPlay;
  41.  
  42. int iPlayCtrlMain(tsevent *ts);
  43. int    iPlayCtrlInit(tsevent *ts);
  44. int iPlayCtrlEnd(tsevent *ts);
  45. int iPlayCtrlPause(tsevent *ts);
  46. int    iPlayCtrlRestart(tsevent *ts);
  47.  
  48. job_t    jobPlayCtrl = {
  49.                         NULL,
  50.                         iPlayCtrlMain,
  51.                         iPlayCtrlInit,
  52.                         iPlayCtrlEnd,
  53.                         iPlayCtrlPause,
  54.                         iPlayCtrlRestart,
  55.                         0 };
  56.  
  57.  
  58. int    iPlayCtrlMain(tsevent *ts)
  59. {
  60.     int        i;
  61.  
  62.     if ( iPlayFlag == 0 ) {
  63.          if ( stPlayList.iPlayCount < stPlayList.iMusicCount) {
  64.  
  65.             if ( iPlayMode == PLAY_RANDOM ) {
  66.                 i = rand() % stPlayList.iMusicCount;
  67.                 while ( stPlayList.pstPlayList[i].iPlayFlag ) {
  68.                     i = rand() % stPlayList.iMusicCount;
  69.                 }
  70.                 stPlayList.pstPlayList[i].iPlayFlag = 1;
  71.             }
  72.             else {
  73.                 i = stPlayList.iPlayingNo;
  74.             }
  75.  
  76.             strcpy(acFileName,stPlayList.pstPlayList[i].acFileName);
  77.  
  78.             iPlayFlag = 1;
  79.             
  80.             ChainAJob(0,&jobPcmPlay);    
  81.  
  82.             stPlayList.iPlayCount++;
  83.             stPlayList.iPlayingNo = i + 1;
  84.  
  85.             iPlayTrack = i + 1;
  86.             iDrawTrack();
  87.  
  88.             pcPlayTitle = stPlayList.pstPlayList[i].acTitle;
  89.             iDrawTitle();
  90.         }
  91.         else {
  92.             UnchainJob();
  93.             return 0;
  94.         }
  95.     }
  96.  
  97.     return 0;
  98. }
  99.  
  100. int    iPlayCtrlInit(tsevent *ts)
  101. {
  102.     int    i;
  103.  
  104.     pImageH[0] = pImgPauseButton;
  105.     pImageL[0] = pImgPushPauseButton;
  106.     DrawAPM(&mCtrlButton,0);
  107.     iPlayFlag = 0;
  108.  
  109.  
  110.     for ( i = 0; i < stPlayList.iMusicCount; i++ ) {
  111.         stPlayList.pstPlayList[i].iPlayFlag = 0;
  112.     }
  113.  
  114.  
  115.     return 0;
  116. }
  117.  
  118. int    iPlayCtrlEnd(tsevent *ts)
  119. {
  120.  
  121.     iPlayFlag = 0;
  122.     iIsPlaying = 0;
  123.  
  124.     pImageH[0] = pImgPlayButton;
  125.     pImageL[0] = pImgPushPlayButton;
  126.     DrawAPM(&mCtrlButton,0);
  127.  
  128.     iPlayMode = PLAY_NORMAL;
  129.  
  130.  
  131.     if ( stPlayList.iMusicCount > 0 ) {
  132.         iPlayTrack = 1;
  133.         pcPlayTitle = stPlayList.pstPlayList[0].acTitle;
  134.     }
  135.     else {
  136.         iPlayTrack = 0;
  137.         pcPlayTitle = NULL;
  138.     }
  139.  
  140.     iDrawTrack();
  141.     iDrawTitle();
  142.  
  143.     stPlayList.iPlayCount = 0;
  144.     stPlayList.iPlayingNo = 0;
  145.  
  146.     return 0;
  147. }
  148.  
  149. int    iPlayCtrlPause(tsevent *ts)
  150. {
  151.     SleepJob(&jobPcmPlay);
  152.     pImageH[0] = pImgRestartButton;
  153.     pImageL[0] = pImgPushRestartButton;
  154.     DrawAPM(&mCtrlButton,0);
  155.  
  156.     return 0;
  157. }
  158.  
  159. int    iPlayCtrlRestart(tsevent *ts)
  160. {
  161.     AwakeJob(&jobPcmPlay);
  162.     pImageH[0] = pImgPauseButton;
  163.     pImageL[0] = pImgPushPauseButton;
  164.     DrawAPM(&mCtrlButton,0);
  165.  
  166.     return 0;
  167. }
  168.